var WebSocket = require('ws');
/* {
	from: 'ybf',
	to: 'll',
	data: 'something'
}
 */
var wss = new WebSocket.Server({
	port: 8083
});
var clientArr = {};
wss.on('connection', function (ws,req) {
	clientArr[req.url.replace('/','')] = ws;
  ws.on('message', function (message,req) {
		message = JSON.parse(message);
		if(clientArr[message.to].readyState == WebSocket.OPEN){
			clientArr[message.to].send(JSON.stringify(message));
		}else{
			delete clientArr[message.to];
		}
	});
});